﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace WpfDecorator
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        ReflectorAdorner adorner;
        MaskAdorner maskDorner;

        public MainWindow()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }


        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
       
            var layer = AdornerLayer.GetAdornerLayer(gridMain);
            var layerq = AdornerLayer.GetAdornerLayer(button1);

            layer.Add(new ReflectorAdorner(button1));
            adorner = new ReflectorAdorner(img);
            layer.Add(adorner);
            //maskDorner = new MaskAdorner(gridMain);
            //layer.Add(maskDorner);

            TextBlock tb = new TextBlock();
            tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            //tb.FlowDirection = System.Windows.FlowDirection.RightToLeft;
            tb.Text = "RightToLeft";
            tb.Foreground = Brushes.White;


            AdornerDecorator AdornerDecorator;

            this.gridMain.Children.Add(tb);

            var adornerLayer = AdornerLayer.GetAdornerLayer(tb);
            adornerLayer.Add(new SimpleTextBlockAdorner(tb));
        }

        bool isShow = false;
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            adorner.HiddenReflector();

            //if (isShow)
            //    maskDorner.Hidden();
            //else
            //    maskDorner.Show();

            isShow = !isShow;
        }


    }
}
